#!/usr/bin/python
from rap_core import *


# ------------------------------------------------------------------------------
# functions acting on sub-shells
# ------------------------------------------------------------------------------

if rlf_subshell(1) != '1s':
  print 'rlf_subshell failed'
if rlf_subshell(10) != '4f':
  print 'rlf_subshell failed'


if rlf_ssindex('1s') != 1:
  print 'rlf_ssindex failed'
if rlf_ssindex('4f') != 10:
  print 'rlf_ssindex failed'
if rlf_ssindex('kp') != -2:
  print 'rlf_ssindex failed'


if rlf_ssdecode(1) != (1,0):
  print 'rlf_ssdecode failed'
if rlf_ssdecode('1s') != (1,0):
  print 'rlf_ssdecode failed'
if rlf_ssdecode(10) != (4,3):
  print 'rlf_ssdecode failed'
if rlf_ssdecode('4f') != (4,3):
  print 'rlf_ssdecode failed'


if rlf_ssoccupancy(1) != 2:
  print 'rlf_ssoccupancy failed'
if rlf_ssoccupancy(10) != 14:
  print 'rlf_ssoccupancy failed'


chk=['2p','2s','1s']
chk.sort(rlf_sssorter)
if chk != ['1s','2s','2p']:
  print 'rlf_sssorter failed'


# ------------------------------------------------------------------------------
# functions acting term strings
# ------------------------------------------------------------------------------

if rlf_termdecode('3F') != (3,3):
  print 'rlf_termdecode() failed'


if rlf_termencode(3,3) != '3F':
  print 'rlf_termencode() failed'


if rlf_termweight('3F') != 21:
  print 'rlf_termweight() failed'


if rlf_term_2jvals('3F') != [4,6,8]:
  print 'rlf_term_2jvals() failed'


# ------------------------------------------------------------------------------
# numerical functions
# ------------------------------------------------------------------------------

print 'rlf_aitken not tested'


# ------------------------------------------------------------------------------
# xstar functions
# ------------------------------------------------------------------------------

if xstar_ionencode(7,7) != 22:
  print 'xstar_ionencode() failed'


if xstar_iondecode(22) != (7,7):
  print 'xstar_iondecode() failed'


# ------------------------------------------------------------------------------
# ADAS functions
# ------------------------------------------------------------------------------

if rlf_adas2float('1.23-01') != 0.123:
  print 'rlf_adas2float() failed'


# ------------------------------------------------------------------------------
# miscellaneous functions
# ------------------------------------------------------------------------------

try:
  tsize=rlf_termsize()
except:
  print 'rlf_termsize() failed'


if not rlf_equiv([1,1,1,1]):
  print 'rlf_equiv() failed'
if rlf_equiv([1,2,3,4]):
  print 'rlf_equiv() failed'


if rlf_binom(10,3) != 120:
  print 'rlf_binom() failed'


if rlf_ordinal(2) != '2nd':
  print 'rlf_ordinal() failed'
if rlf_ordinal(4) != '4th':
  print 'rlf_ordinal() failed'





print '*done'
